package com.crm.miaohe.mapper;

import com.crm.miaohe.model.TblPriceStrategy;
import com.crm.miaohe.model.TblPriceStrategyExample;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface TblPriceStrategyMapper {
    long countByExample(TblPriceStrategyExample example);

    int deleteByExample(TblPriceStrategyExample example);

    @Delete({
            "delete from tbl_price_strategy",
            "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
            "insert into tbl_price_strategy (strategy_name, approved, ",
            "is_default, is_locked,remark, create_time, ",
            "create_user, update_time, ",
            "update_user, version)",
            "values (#{strategyName,jdbcType=VARCHAR}, #{approved,jdbcType=BIT}, ",
            "#{isDefault,jdbcType=BIT},#{isLocked,jdbcType=BIT}, #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
            "#{createUser,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, ",
            "#{updateUser,jdbcType=VARCHAR}, #{version,jdbcType=BIGINT})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Long.class)
    int insert(TblPriceStrategy record);

    int insertSelective(TblPriceStrategy record);

    List<TblPriceStrategy> selectByExample(TblPriceStrategyExample example);

    @Select({
            "select",
            "id, strategy_name, approved, is_default, is_locked, remark, create_time, create_user, update_time, ",
            "update_user, version",
            "from tbl_price_strategy",
            "where id = #{id,jdbcType=BIGINT}"
    })
    @ResultMap("com.crm.miaohe.mapper.TblPriceStrategyMapper.BaseResultMap")
    TblPriceStrategy selectByPrimaryKey(Long id);

    int updateByExampleSelective(@Param("record") TblPriceStrategy record, @Param("example") TblPriceStrategyExample example);

    int updateByExample(@Param("record") TblPriceStrategy record, @Param("example") TblPriceStrategyExample example);

    int updateByPrimaryKeySelective(TblPriceStrategy record);

    @Update({
            "update tbl_price_strategy",
            "set strategy_name = #{strategyName,jdbcType=VARCHAR},",
            "approved = #{approved,jdbcType=BIT},",
            "is_default = #{isDefault,jdbcType=BIT},",
            "is_locked = #{isLocked,jdbcType=BIT},",
            "remark = #{remark,jdbcType=VARCHAR},",
            "create_time = #{createTime,jdbcType=TIMESTAMP},",
            "create_user = #{createUser,jdbcType=VARCHAR},",
            "update_time = #{updateTime,jdbcType=TIMESTAMP},",
            "update_user = #{updateUser,jdbcType=VARCHAR},",
            "version = #{version,jdbcType=BIGINT}",
            "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(TblPriceStrategy record);
}